import cgi
import os
from datetime import date

from google.appengine.api import users
from google.appengine.api import mail
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app

class Partida(db.Model):
	organizador = db.UserProperty()
	participantes = db.ListProperty(users.User)
	fecha = db.DateProperty(auto_now_add=True)

class MainPage(webapp.RequestHandler):
	def get(self):
		usuario = users.get_current_user()
		url_salir = users.create_logout_url(self.request.uri)

		if usuario:
			tmpl_vals = {'usuario'		: usuario,
						 'url_salir'	: url_salir}	
			path = os.path.join(os.path.dirname(__file__), 'tmpl/bienvenida.html')
			self.response.out.write(template.render(path, tmpl_vals))
		else:
			self.redirect(users.create_login_url(self.request.uri))

class CrearPartida(webapp.RequestHandler):
	def get(self):
	def post(self):

class ObtenerAmigo(webapp.RequestHandler):
	def get(self):
	def post(self):

class DescubrirAmigo(webapp.RequestHandler):
	def get(self):
	def post(self):

application = webapp.WSGIApplication([('/', MainPage), 
									  ('/crear', CrearPartida), 
									  ('/obtener', ObtenerAmigo), 
									  ('/descubrir', DescubrirAmigo)], debug=True)

def main():
	run_wsgi_app(application)

if __name__ == "__main__":
	main()
